Skip to content

fix: resolve Windows native SCSS import failures in dev server#44118

Open
anarefolio wants to merge 1 commit intogithub:mainfrom
anarefolio:fix/windows-sass-import-resolution
Open

fix: resolve Windows native SCSS import failures in dev server#44118
anarefolio wants to merge 1 commit intogithub:mainfrom
anarefolio:fix/windows-sass-import-resolution

Conversation

@anarefolio
Copy link
Copy Markdown

Problem

Running npm run dev on Windows (native, no WSL) fails with:
Error: Can't find stylesheet to import.
@import './themes/light.scss'

Root cause

Three compounding issues in Next.js's bundled sass-loader:

  1. Uses legacy sass API which doesn't support loadPaths
  2. webpackImporter defaults to true, webpack loses path context on Windows
  3. @primer/primitives v11 (installed) conflicts with v7 expected by @primer/css

Fix

Patch to next@16.2.3 compiled sass-loader that:

  1. Forces modern-compiler API (enables loadPaths)
  2. Sets webpackImporter default to false
  3. Adds node_modules to loadPaths

Applied via patch-package — runs automatically on npm install.

Tested on Windows 11, Node.js 24, native (no WSL).

Note: The contributing guide states "This site can be developed on Windows"
but the current setup fails for native Windows users due to these sass-loader
issues. This fix makes that statement actually true.

On Windows, Next.js's bundled sass-loader fails to resolve SCSS imports
from node_modules due to path resolution issues with resolve-url-loader
and the legacy sass API.

This patch to next@16.2.3's compiled sass-loader makes three changes:
1. Forces modern-compiler API instead of legacy, enabling loadPaths support
2. Disables webpackImporter (defaults to false) so sass uses its own
   native resolver instead of webpack's, which loses path context on Windows
3. Adds node_modules to loadPaths so package-style @import statements
   like @primer/css and @primer/primitives resolve correctly

Also adds loadPaths to sassOptions in next.config.ts as the proper
configuration surface for this fix.

Fixes dev server startup on Windows (native, no WSL required).
Tested on Windows 11 with Node.js 24.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

How to review these changes 👓

Thank you for your contribution. To review these changes, choose one of the following options:

A Hubber will need to deploy your changes internally to review.

Table of review links

Note: Please update the URL for your staging server or codespace.

This pull request contains code changes, so we will not generate a table of review links.

🤖 This comment is automatically generated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

triage Do not begin working on this issue until triaged by the team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant